<?php
// 'Blog' and 'Blogger' are one, I just use 'Blogger' for no reason!
class Blogger extends Controller {
	private $_view_data;
	private $_current_blogger_uri; // the URL-Suffix of this Blog
	private $_current_blogger_id; // the id of this Blog
	private $_blog_info;
	private $_is_community_member;
	private $_is_blog_owner;
	private $_is_blog_friend;
	private $_current_user_id; // the id of the current visitor: 0 for guest
	
	function Blogger() {
		
		parent::Controller();
		
//		$this->output->enable_profiler(TRUE);
		
		$enabled = $this->config->item('Enabled');
		if(!$enabled) {
			show_error('OoW = Out of Work!');
		}
		
		$this->load->library('common');
		$this->load->library('auth');
		$this->load->library('cache');
		$this->load->library('user_agent');
		
		$this->load->model('Blogger_Manager');
		$this->load->model('Identity_Manager');
		$this->load->model('Tag_Manager');
		$this->load->model('Entry_Manager');
		
		// init...
		$this->_current_blogger_uri = $this->common->GetCurrentBloggerURI();
		$this->_view_data['blogger_uri'] = $this->_current_blogger_uri;
		
		$current_blogger_id_username = $this->common->GetBloggerIDUserName($this->_current_blogger_uri);
/*		$this->_current_blogger_id = $current_blogger_id_username->id;
		if($this->_current_blogger_id <= 0) {
			show_error('Specified Blog does not exist!');
		}*/
		if(is_null($current_blogger_id_username)) {
			show_error('Specified Blog does not exist!');
		}
		$this->_current_blogger_id = $current_blogger_id_username->id;
		
		// blog basic info
		$this->_blog_info = $this->cache->Load('blog_basic_info_' . $this->_current_blogger_id);
		if(!$this->_blog_info) {
			$this->_blog_info = $this->Blogger_Manager->GetBloggerInfo($this->_current_blogger_id);
			$this->cache->Store('blog_basic_info_' . $this->_current_blogger_id, json_encode($this->_blog_info));
		} else {
			$this->_blog_info = json_decode($this->_blog_info);
		}
		$this->_blog_info->announcement = $this->common->UBBCode($this->_blog_info->announcement);
		$this->_view_data['blog_info'] = $this->_blog_info;
		
		// identity check
		$this->Identity_Manager->DoIdentityCheck($this->_blog_info);
		$this->_is_community_member = $this->Identity_Manager->IsCommunityMember();
		$this->_is_blog_friend = $this->Identity_Manager->IsBlogFriend();
		$this->_is_blog_owner = $this->Identity_Manager->IsBlogOwner();
		$this->_current_user_id = $this->Identity_Manager->CurrentUserID();
		
		$this->_view_data['is_community_member'] = $this->_is_community_member;
		$this->_view_data['is_blog_friend'] = $this->_is_blog_friend;
		$this->_view_data['is_blog_owner'] = $this->_is_blog_owner;
		$this->_view_data['current_user_id'] = $this->_current_user_id;
		if($this->_current_user_id > 0) {
			$this->_view_data['current_user_name'] = $this->Identity_Manager->CurrentUserData()->user_name;
		}
		
		// common parts
		$cates = $this->cache->Load('blog_custom_category_list_' . $this->_current_blogger_id);
		if(!$cates) {
			$cates = $this->Blogger_Manager->GetBlogCustomCategoryList($this->_current_blogger_id);
			$this->cache->Store('blog_custom_category_list_' . $this->_current_blogger_id, json_encode($cates));
		} else {
			$cates = json_decode($cates);
		}
		$this->_view_data['custom_categories'] = $cates;
		
		$arcs = $this->cache->Load('blog_archive_list_' . $this->_current_blogger_id);
		if(!$arcs) {
			$arcs = $this->Blogger_Manager->GetBlogArchiveList($this->_current_blogger_id);
			$this->cache->Store('blog_archive_list_' . $this->_current_blogger_id, json_encode($arcs));
		} else {
			$arcs = json_decode($arcs);
		}
		$this->_view_data['blog_archives'] = $arcs;
		
		$links = $this->cache->Load('blog_link_list_' . $this->_current_blogger_id);
		if(!$links) {
			$links = $this->Blogger_Manager->GetLinks($this->_current_blogger_id);
			$this->cache->Store('blog_link_list_' . $this->_current_blogger_id, json_encode($links));
		} else {
			$links = json_decode($links);
		}
		$this->_view_data['links'] = $links;
		
		// tag init
		$this->Tag_Manager->SetCurrentBloggerID($this->_current_blogger_id);
		
		// entry init
		$this->Entry_Manager->SetCurrentBloggerID($this->_current_blogger_id);
		
		// load cookies for commenting and messaging
		$last_comment_name = $this->common->GetCookie('last_comment_name');
		$last_comment_email = $this->common->GetCookie('last_comment_email');
		$last_comment_url = $this->common->GetCookie('last_comment_url');
		
		$this->_view_data['last_comment_name'] = ($last_comment_name === FALSE) ? '' : $last_comment_name;
		$this->_view_data['last_comment_email'] = ($last_comment_email === FALSE) ? '' : $last_comment_email;
		$this->_view_data['last_comment_url'] = ($last_comment_url === FALSE) ? '' : $last_comment_url;
		
		$last_pm_sender_name = $this->common->GetCookie('last_pm_sender_name');
		$last_pm_sender_email = $this->common->GetCookie('last_pm_sender_email');
		
		$this->_view_data['last_pm_sender_name'] = ($last_pm_sender_name === FALSE) ? '' : $last_pm_sender_name;
		$this->_view_data['last_pm_sender_email'] = ($last_pm_sender_email === FALSE) ? '' : $last_pm_sender_email;
		
		// if is owner, notify for new messages
		if($this->_is_blog_owner) {
			$this->load->model('Message_Manager');
			$this->Message_Manager->SetCurrentBloggerID($this->_current_blogger_id);
			$new_msg_num = $this->Message_Manager->GetUnreadPMNum();
			$this->_view_data['new_msg_num'] = $new_msg_num;
		}
		
		// load language
		$this->lang->load('n8_blog');
		
		$ie_warning = FALSE;
		// ie-warning
		if($this->agent->is_browser()) {
			if(strpos(strtolower($this->agent->browser()), 'internet explorer') !== FALSE) {
				$ie_warning = TRUE;
			}
		}
		$this->_view_data['ie_warning'] = $ie_warning;
	}
	
	function index($blogger_uri, $page_num = 1) {
		$page_size = 10;
		
		if($page_num > 1) {
			$top_entries = $this->Blogger_Manager->GetPageEntries($this->_current_blogger_id, $page_size, $page_num);
		} else {
			// recent entries
			$top_entries = $this->cache->Load('blog_recent_entries_' . $this->_current_blogger_id);
			if(!$top_entries) {
				$top_entries = $this->Blogger_Manager->GetRecentEntries($this->_current_blogger_id, 10);
				$this->cache->Store('blog_recent_entries_' . $this->_current_blogger_id, json_encode($top_entries));
			} else {
				$top_entries = json_decode($top_entries);
			}
		}
		$now = $this->common->Now();
		foreach($top_entries as $te) {
			$pr = FALSE;
			if($te->state == 3) { // community only entry
				if(!$this->_is_community_member) {
					$te->id = -1;
					$te->title = '';
					$te->content = '<p class="entryIsCommunityOnly">' . lang('n8_blog_promptEntryIsInternal') . '</p>';
					$te->comment_num = 'n/a';
					$te->category_title = 'n/a';
					$te->tags = '';
					$pr = TRUE;
				}
			}
			if($te->state == 0) { // secret entry, friends only
				if(!$this->_is_blog_friend) {
					$te->id = -1;
					$te->title = '';
					$te->content = '<p class="entryIsSecret">' . lang('n8_blog_promptEntryIsSecret') . '</p>';
					$te->comment_num = 'n/a';
					$te->category_title = 'n/a';
					$te->tags = '';
					$pr = TRUE;
				}
			}
			if(!$pr) {
				$te->content = $this->common->UBBCode($this->common->MoreMode($te->content, $this->_current_blogger_uri, $te->id));
			}
			$te->post_time = $this->common->NicerTime($te->post_time);
		}
		$this->_view_data['recent_entries'] = $top_entries;
		// paging url
		if($page_num > 2) {
			$this->_view_data['prev_page_url'] = '/page/' . ($page_num - 1);
		} else {
			$this->_view_data['prev_page_url'] = '';
		}
		$this->_view_data['next_page_url'] = '/page/' . ($page_num + 1);
		
		// recent comments
		$recent_comments = $this->cache->Load('blog_recent_comment_list_' . $this->_current_blogger_id);
		if(!$recent_comments) {
			$recent_comments = $this->Blogger_Manager->GetRecentComments($this->_current_blogger_id, 10);
			$this->cache->Store('blog_recent_comment_list_' . $this->_current_blogger_id, json_encode($recent_comments));
		} else {
			$recent_comments = json_decode($recent_comments);
		}
		foreach($recent_comments as $rc) {
			$pr = FALSE;
			if($rc->entry_state == 3) { // community only entry
				if(!$this->_is_community_member) {
					$rc->id = -1;
					$pr = TRUE;
				}
			}
			if($rc->entry_state == 0) { // secret entry, friends only
				if(!$this->_is_blog_friend) {
					$rc->id = -1;
					$pr = TRUE;
				}
			}
			if(!$pr) {
				if(mb_strlen($rc->content, 'UTF-8') > 48) { // comment preview length
					$rc->content = mb_substr($rc->content, 0, 48, 'UTF-8') . '...';
				}
			}
		}
		$this->_view_data['recent_comments'] = $recent_comments;
		
		// tag cloud
		$tags = $this->cache->Load('blog_tag_list_' . $this->_current_blogger_id);
		if(!$tags) {
			$tags = $this->Tag_Manager->CalcTagLevel($this->Tag_Manager->GetTagList());
			$this->cache->Store('blog_tag_list_' . $this->_current_blogger_id, json_encode($tags));
		} else {
			$tags = json_decode($tags);
		}
		$this->_view_data['tags'] = $tags;
		
		$agent_is_ipod = $this->agent->is_mobile();
		if($agent_is_ipod) {
			if($this->_is_blog_owner) {
				// get data for posting new entry
				// category list
				$cates_list = $this->Blogger_Manager->GetBlogCustomCategoryList($this->_current_blogger_id);
				$this->_view_data['custom_cates'] = $cates_list;
			}
			$this->load->view('mobile/blog_view', $this->_view_data);
		} else {
			$this->load->view('blog/blog_view', $this->_view_data);
		}
	}
	
	function entry($blogger_uri, $entry_id) {
		$now = $this->common->Now();
		// get entry
		try {
			$entry = $this->Entry_Manager->RetrieveEntry($entry_id);
		} catch(Exception $ex) {
			show_error($ex->getMessage());
		}
		$pr = FALSE;
		if($entry->state == 3) { // community only entry
			if(!$this->_is_community_member) {
				$entry->title = lang('n8_blog_entryIsInternalTitle');
				$entry->category_title = 'n/a';
				$entry->tags = '';
				$entry->content = '<p class="entryIsCommunityOnly">' . lang('n8_blog_promptEntryIsInternal') . '</p>';
				$entry->comment_num = 'n/a';
				$pr = TRUE;
			}
		}
		if($entry->state == 0) { // secret entry
			if(!$this->_is_blog_friend) {
				$entry->title = lang('n8_blog_entryIsSecretTitle');
				$entry->category_title = 'n/a';
				$entry->tags = '';
				$entry->content = '<p class="entryIsSecret">' . lang('n8_blog_promptEntryIsSecret') . '</p>';
				$entry->comment_num = 'n/a';
				$pr = TRUE;
			}
		}
		if($entry->state == 99) { // draft, owner only!
			if(!$this->_is_blog_owner) {
				die('Unknown Exception...');
			}
		}
		if(!$pr) {
			$entry->content = $this->common->UBBCode($entry->content);
		}
		$entry->post_time = $this->common->NicerTime($entry->post_time);
		$this->_view_data['entry_info'] = $entry;
		
		// update subscription for read
		if($this->_current_user_id > 0) {
			$this->load->model('Subscription_Manager');
			$this->Subscription_Manager->SetCurrentBloggerID($this->_current_user_id);
			
			$this->Subscription_Manager->SetItemViewed($entry_id);
		}
		
		// an older entry
		$prev_entry = $this->Entry_Manager->GetPrevEntryInfo($entry_id);
		$this->_view_data['prev_entry_info'] = $prev_entry;
		
		// an newer entry
		$next_entry = $this->Entry_Manager->GetNextEntryInfo($entry_id);
		$this->_view_data['next_entry_info'] = $next_entry;
		
		// comments
		$comments = $this->Entry_Manager->GetEntryCommentList($entry_id);
		foreach($comments as $cmt) {
			$cmt->content = $this->common->UBBCode($cmt->content, FALSE);
			if(!$this->_is_blog_owner) {
				$cmt->ip = '';
			} else {
				$cmt->ip = ' [' . $cmt->ip . ']';
			}
			$cmt->post_time = $this->common->NicerTime($cmt->post_time);
		}
		$this->_view_data['comments'] = $comments;
		
		$agent_is_ipod = $this->agent->is_mobile();
		if($agent_is_ipod) {
			if($this->_is_blog_owner) {
				// get data for posting new entry
				// category list
				$cates_list = $this->Blogger_Manager->GetBlogCustomCategoryList($this->_current_blogger_id);
				$this->_view_data['custom_cates'] = $cates_list;				
			}
			$this->load->view('mobile/entry_view', $this->_view_data);
		} else {
			$this->load->view('blog/entry_view', $this->_view_data);
		}
	}
	
	function comments_list($blogger_uri, $entry_id) {
		// get entry (for security)
		try {
			$entry = $this->Entry_Manager->RetrieveEntry($entry_id);
		} catch(Exception $ex) {
			show_error($ex->getMessage());
		}
		$pr = FALSE;
		if($entry->state == 3) { // community only entry
			if(!$this->_is_community_member) {
				show_error('You cannot view community-only entry!');
			}
		}
		if($entry->state == 0) { // secret entry
			if(!$this->_is_blog_friend) {
				show_error('You cannot view secret entry!');
			}
		}
		if($entry->state == 99) { // draft, owner only!
			if(!$this->_is_blog_owner) {
				die('Unknown Exception...');
			}
		}
		// comments
		$comments = $this->Entry_Manager->GetEntryCommentList($entry_id);
		foreach($comments as $cmt) {
			$cmt->content = $this->common->UBBCode($cmt->content, FALSE);
			if(!$this->_is_blog_owner) {
				$cmt->ip = '';
			} else {
				$cmt->ip = ' [' . $cmt->ip . ']';
			}
			$cmt->post_time = $this->common->NicerTime($cmt->post_time);
		}
		$this->_view_data['comments'] = $comments;
		
		// mobile?
		$agent_is_iphone = $this->agent->is_mobile();
		if($agent_is_iphone) {
			$this->load->view('mobile/entry_comments_list_view', $this->_view_data);
		} else {
			$this->load->view('blog/entry_comments_list_view', $this->_view_data);
		}		
	}
	
	function archive($blogger_uri, $year = 0, $month = 0) {
		if($year == 0 || $month == 0 || $month > 12) {
			show_error('Invalid Year-Month!');
		}
		$this->_view_data['archive_list_title'] = $month . ' / ' . $year;
		
		$month_entries = $this->Blogger_Manager->GetEntriesByMonth($this->_current_blogger_id, $year, $month);
		foreach($month_entries as $me) {
			$pr = FALSE;
			if($me->state == 3) { // community only entry
				if(!$this->_is_community_member) {
					$me->id = -1;
					$me->title = '';
					$me->content_top = '<p class="entryIsCommunityOnly">' . lang('n8_blog_promptEntryIsInternal') . '</p>';
					$me->comment_num = 'n/a';
					$me->tags = '';
					$pr = TRUE;
				}
			}
			if($me->state == 0) { // secret entry, friends only
				if(!$this->_is_blog_friend) {
					$me->id = -1;
					$me->title = '';
					$me->content_top = '<p class="entryIsSecret">' . lang('n8_blog_promptEntryIsSecret') . '</p>';
					$me->comment_num = 'n/a';
					$me->tags = '';
					$pr = TRUE;
				}
			}
			if(!$pr) {
				$me->content_top = $this->common->HTMLSpecChars($me->content_top);
			}
			$me->post_time = $this->common->NicerTime($me->post_time);
		}
		$this->_view_data['month_entries'] = $month_entries;
		
		$this->load->view('blog/archive_view', $this->_view_data);
	}
	
	function category($blogger_uri, $cate_id) {
		if($cate_id > 1) {
			$cate_info = $this->Blogger_Manager->GetCategoryTitleDescByID($this->_current_blogger_id, $cate_id);
			$this->_view_data['category_title'] = $cate_info->title;
			$this->_view_data['category_desc'] = $cate_info->description;
		} else {
			$this->_view_data['category_title'] = lang('n8_blog_entryCategoryDefaultTitle');
			$this->_view_data['category_desc'] = lang('n8_blog_entryCategoryDefaultDesc');
		}
		
		$cate_entries = $this->Blogger_Manager->GetEntriesByCategory($this->_current_blogger_id, $cate_id);
		foreach($cate_entries as $ce) {
			$pr = FALSE;
			if($ce->state == 3) { // community only entry
				if(!$this->_is_community_member) {
					$ce->id = -1;
					$ce->title = '';
					$ce->content_top = '<p class="entryIsCommunityOnly">' . lang('n8_blog_promptEntryIsInternal') . '</p>';
					$ce->comment_num = 'n/a';
					$ce->tags = '';
					$pr = TRUE;
				}
			}
			if($ce->state == 0) { // secret entry, friends only
				if(!$this->_is_blog_friend) {
					$ce->id = -1;
					$ce->title = '';
					$ce->content_top = '<p class="entryIsSecret">' . lang('n8_blog_promptEntryIsSecret') . '</p>';
					$ce->comment_num = 'n/a';
					$ce->tags = '';
					$pr = TRUE;
				}
			}
			if(!$pr) {
				$ce->content_top = $this->common->HTMLSpecChars($ce->content_top);
			}
			$ce->post_time = $this->common->NicerTime($ce->post_time);
		}
		$this->_view_data['category_entries'] = $cate_entries;
		
		$this->load->view('blog/category_view', $this->_view_data);
	}
	
	function tag($blogger_uri, $tag_query) {
		$tag_query = trim($tag_query);
		if($tag_query == '') {
			show_error('No Tag specified!');
		}
		
		$tag_query = urldecode($tag_query);
		$tag_query = str_replace(' ', '+', $tag_query); // space means +
		
		$tag_list = $this->Tag_Manager->GetTagList();
		$tag_entries = $this->Tag_Manager->GetEntryListByTag($tag_query);
		foreach($tag_entries as $te) {
			$te->content_top = $this->common->HTMLSpecChars($te->content_top);
			$te->post_time = $this->common->NicerTime($te->post_time);
		}
		
		$this->_view_data['tag_list'] = $tag_list;
		$this->_view_data['tag_entries'] = $tag_entries;
		$this->_view_data['tag_string'] = $tag_query;
		
		$this->load->view('blog/tag_view', $this->_view_data);
	}
	
	function comment($blogger_uri, $entry_id) {
		$is_post_back = $this->input->post('hidIsPostBack');
		$result = '';
		if($is_post_back == 'ja') {
			$this->load->model('Comment_Manager');
			$this->Comment_Manager->SetCurrentBloggerID($this->_current_blogger_id);
			
			$comment_state = 1;
			if(($this->_is_community_member === FALSE) && ($this->_blog_info->allow_public_comment == 0)) {
				$comment_state = 0;
			}
			
			$pdata = json_decode($this->input->post('posted_data'));
			
			// place-holder for spam checking?
			
			$now = $this->common->Now();
			$comment = array(
				'entry_id' => $entry_id,
				'author_name' => ($pdata->author_name == '') ? lang('n8_blog_commentAnonymous') : $pdata->author_name,
				'email' => $pdata->email,
				'post_time' => $now,
				'ip' => $this->input->ip_address(),
				'url' => $pdata->url,
				'state' => $comment_state,
				'by_blogger_id' => $this->_current_user_id,
				'content' => $pdata->content
			);
			$new_comment_id = $this->Comment_Manager->AddComment($comment);
			
			$this->common->SetCookie('last_comment_name', $pdata->author_name, 28);
			$this->common->SetCookie('last_comment_email', $pdata->email, 28);
			$this->common->SetCookie('last_comment_url', $pdata->url, 28);
			
			// clean caches!
			$this->cache->Remove('blogger_list');
			$this->cache->Remove('blog_basic_info_' . $this->_current_blogger_id);
			$this->cache->Remove('blog_recent_comment_list_' . $this->_current_blogger_id);
			$this->cache->Remove('blog_recent_entries_' . $this->_current_blogger_id);
			$this->cache->Remove('latest_entries');
			
			// update subscriptions
			$this->load->model('Subscription_Manager');
			$this->Subscription_Manager->SetCurrentBloggerID($this->_current_blogger_id);
			$this->Subscription_Manager->SetEntryUpdated($entry_id, $now);
			
			$result = 'SUCC_' . $new_comment_id;
		}
		echo($result);
	}
	
	function leave_message($blogger_uri) {
		$is_post_back = $this->input->post('hidIsPostBack');
		$result = '';
		if($is_post_back == 'ja') {
			$this->load->model('Message_Manager');
			$this->Message_Manager->SetCurrentBloggerID($this->_current_blogger_id);
			
			$pdata = json_decode($this->input->post('posted_data'));
			$msg = array(
				'sender_name' => $pdata->sender_name,
				'to_blogger_id' => $this->_current_blogger_id,
				'title' => $pdata->title,
				'content' => $pdata->content,
				'sent_time' => $this->common->Now(),
				'sender_email' => $pdata->sender_email,
				'ip' => $this->input->ip_address(),
				'from_blogger_id' => $this->_current_user_id
			);
			
			$this->Message_Manager->SendPrivateMessage($msg);
			
			$this->common->SetCookie('last_pm_sender_name', $pdata->sender_name);
			$this->common->SetCookie('last_pm_sender_email', $pdata->sender_email);
			
			$result = 'SUCC_*';
		}
		echo($result);
	}
	
	function friend_login($blogger_uri) {
		$is_post_back = $this->input->post('hidIsPostBack');
		$result = '';
		if($is_post_back == 'ja') {
			$fr_pwd = $this->input->post('friend_pwd');
			$fr_pwd = md5($fr_pwd);
			if(strcmp($fr_pwd, md5($this->_blog_info->friend_password)) == 0) {
				$this->common->SetCookie('friend_pwd_hash[' . $this->_current_blogger_id . ']', $fr_pwd);
				$result = 'SUCC_*';
			} else {
				$result = 'FAIL_Password error!';
			}
		}
		echo($result);
	}
	
	function add_watch($blogger_uri) {
		$is_post_back = $this->input->post('hidIsPostBack');
		$result = '';
		
		if($is_post_back == 'ja') {
			if(!$this->_is_community_member) {
				$result = 'FAIL_Not community member!';
			} else {
				$entry_id = $this->input->post('entry_id');
				$this->load->model('Subscription_Manager');
				$this->Subscription_Manager->SetCurrentBloggerID($this->_current_user_id);
				$this->Subscription_Manager->AddSubscription($entry_id);
				$result = 'SUCC_*';
			}
		} else {
			$result = 'FAIL_NOT-POST';
		}
		echo($result);
	}
	
	function rss($blogger_uri, $cate_id) {
		$rss_item_count = 10;
		
		if($cate_id == 0) {
			// main rss
			$this->_view_data['is_main_rss'] = TRUE;
			// recent entries
			$top_entries = $this->cache->Load('blog_recent_entries_' . $this->_current_blogger_id);
			if(!$top_entries) {
				$top_entries = $this->Blogger_Manager->GetRecentEntries($this->_current_blogger_id, 10);
				$this->cache->Store('blog_recent_entries_' . $this->_current_blogger_id, json_encode($top_entries));
			} else {
				$top_entries = json_decode($top_entries);
			}
			
			foreach($top_entries as $te) {
				$te->content = $this->common->UBBCode($te->content);
			}
			
			$this->_view_data['entries'] = $top_entries;
		} else {
			$this->load->model('Category_Manager');
			$this->Category_Manager->SetCurrentBloggerID($this->_current_blogger_id);
			$cate_info = $this->Category_Manager->GetCategory($cate_id);
			$entries = $this->Blogger_Manager->GetEntriesByCategory4Feed($this->_current_blogger_id, $cate_id, $rss_item_count);
			$this->_view_data['is_main_rss'] = FALSE;
			$this->_view_data['cate_info'] = $cate_info;
			
			foreach($entries as $te) {
				$te->content = $this->common->UBBCode($this->common->MoreMode($te->content, $this->_current_blogger_uri, $te->id));
			}
			$this->_view_data['entries'] = $entries;
		}
		
		$this->output->set_header('Content-Type: text/xml; charset=utf-8');
		$this->load->view('blog/rss_view', $this->_view_data);
	}
	
	function rss_comment($blogger_uri) {
		$item_count = 10;
		
		$recent_comments = $this->Blogger_Manager->GetRecentComments4RSS($this->_current_blogger_id, $item_count);
		foreach($recent_comments as $rc) {
			$rc->content = $this->common->UBBCode($rc->content);
		}
		
		$this->_view_data['recent_comments'] = $recent_comments;
		
		$this->load->view('blog/rss_comment_view', $this->_view_data);
	}
}
?>
